import com.yxd.connector.http.HttpRequest;
import com.yxd.logging.SysLogger;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

/**
 * Created by Administrator on 2016/6/15.
 */
public class Test implements Servlet {

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        SysLogger.print("init");
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        PrintWriter writer = servletResponse.getWriter();
        HttpRequest request = (HttpRequest) servletRequest;
        List<String> names = Collections.list(request.getHeaderNames());
        for (String name :
                names) {
            String value = request.getHeader(name);
            writer.println(name + "=>" + value);
        }

        writer.println("hello,I am servlet");
        writer.close();
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        SysLogger.print("destroy");
    }
}
